package com.zhentao.kafka;

import com.alibaba.fastjson.JSON;
import com.zhentao.mapper.ActivityMapper;
import com.zhentao.model.common.manger.pojo.Activity;
import com.zhentao.service.ActivityService;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 王越潇
 * @version 1.0
 * @Date 2024/10/4 23:23
 * @Type
 */
@Component
public class ActiveKafka {
    @Resource
    private ActivityMapper activityMapper;
    @KafkaListener(topics = "active")
    public void listen(String message){
        System.out.println("接收到消息："+message);
        Activity activity = JSON.parseObject(message, Activity.class);
        activity.setStatus(2);
        activityMapper.updateById(activity);
    }
    @KafkaListener(topics = "endTime")
    public void listenDelete(String message){
        System.out.println("结束时间："+message);
        Activity activity = JSON.parseObject(message, Activity.class);
        activity.setStatus(1);
        activityMapper.updateById(activity);
    }
}
